package com.example.controller;

import com.example.pojo.Result;
import com.example.service.UserService;
import lombok.extern.slf4j.Slf4j;
import com.example.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version 1.0
 * @Author wql
 * @Date 2024/5/30
 * @Description
 */
@RestController
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/register")
    public Result registr(@RequestBody User user){
        log.info("用户注册:{}",user);
        try {
            userService.register(user);
            System.out.println(user);
            return Result.success();
        } catch (Exception e) {
            return Result.error("注册失败");
        }
    }
}
